<!--
 * @Descripttion: 
 * @version: 
 * @Author: jiating
 * @Date: 2021-02-22 17:03:48
 * @LastEditors: jiating
 * @LastEditTime: 2021-02-24 14:59:55
-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>K5G-C</title>
    <link rel="stylesheet" href="./css/common.css"/>
    <link rel="stylesheet" href="./css/index.css"/>
    <link rel="stylesheet" href="./css/mobile.css"/>
    <link rel="stylesheet" href="./css/modal.css">
</head>

<body>
<div class="main">
    <div class="tit-heade">
        <div class="itemOne">
            <img src="./image/left.png" >
        </div>
        <div class="itemTwo">
            <div class="item-chil">
                <img src="./image/logoutOne.png">
            </div>
            <div class="item-chil">
                <a href="/action/logout">ログアウト</a>
            </div>
            
        </div>
    </div>  
    <div class="nav2">
        <div class="nav-item">
            <div id='x1' class="item" onclick="toPage('./home.html')">ホーム</div>
        </div>
        <div class="nav-item">
            <div id='x2' class="item no-act" onclick="toPage('./mobileData.html')">モバイルネットワーク</div>
            <div class="">
                <div>
                    <div class="">
                        <div class="item1" id="wifi1" onclick="toPage('./mobileData.html')">モバイルデータ設定</div>
                        <div class="item1 choose" id="wifi_list" onclick="toPage('./priorityNetwork.html')">優先ネットワーク設定</div>
                        <div class="item1" id="wifi_list" onclick="toPage('./webSearch.html')">ネットワーク検索設定</div>
                        <div class="item1" id="wifi_list" onclick="toPage('./apn.html')">アクセスポイント設定</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="nav-item">
            <div id='x3' class="item no-act" onclick="toPage('./wifi.html')">Wi-Fi設定</div>
        </div>
        <div class="nav-item">
            <div id='x4' class="item no-act" onclick="toPage('./dhcp.html')">Ethernet設定</div>
        </div>
        <div class="nav-item">
            <div id='x5' class="item no-act" onclick="toPage('./port.html')">LAN設定</div>
            
        </div>
        <div class="nav-itm">
            <div id='x6' class="item no-act" onclick="toPage('./password.html')">端末設定</div>
        </div>
    </div>

    <div id="mobile" class="content">
        <div class="title">優先ネットワーク</div>

        <div style="margin-left: 100px;margin-top: 10px;">
            <p>優先するモバイルネットワークを選択することができます。</p>
            <p>「NR/LTE」に設定すると、NR＞LTEの優先順で自動選択します。</p>
        </div>

        <div id="sim0">
            <div class="form-box" style="padding: 30px">
                <div style="color: #333333; font:bold; font-size: 24px; border-bottom: 1px solid #000">SIM1
                </div>
            </div>

            <form action="" class="default-form">
                <table class="input-table">
                    <tbody>
                        <tr>
                            <th><label class="default-label" for="">優先ネットワーク</label></th>
                            <td>
                                <label style="display: block;">
                                    <input onclick="security_click(11)" class="a-radio" type="radio" name="preferred-network0"
                                        value="11"><span class="b-radio"></span>LTE
                                </label>
                                <label style="display: block;">
                                    <input onclick="security_click(23)" class="a-radio" type="radio" name="preferred-network0"
                                        value="23" checked><span class="b-radio"></span>NR のみ
                                </label>
                                <label style="display: block;">
                                    <input onclick="security_click(24)" class="a-radio enhancedOpen" type="radio"
                                        name="preferred-network0" value="24"><span class="b-radio"></span>NR / LTE
                                </label>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <div class="horizontal-box" style="margin-top: 40px">
                <div class="submit-btn" onclick="freshen_click(0)">設定</div>
            </div>
        </div>

        <div id="sim1">

            <div class="form-box" style="padding: 30px">
                <div style="color: #333333; font:bold; font-size: 24px; border-bottom: 1px solid #000">SIM2
                </div>
            </div>

            <form action="" class="default-form">
                <table class="input-table">
                    <tbody>
                        <tr>
                            <th><label class="default-label" for="">優先ネットワーク</label></th>
                            <td>
                                <label style="display: block;">
                                    <input onclick="security_click(11)" class="a-radio" type="radio" name="preferred-network1"
                                        value="11"><span class="b-radio"></span>LTE
                                </label>
                                <label style="display: block;">
                                    <input onclick="security_click(23)" class="a-radio" type="radio" name="preferred-network1"
                                        value="23" checked><span class="b-radio"></span>NR のみ
                                </label>
                                <label style="display: block;">
                                    <input onclick="security_click(24)" class="a-radio enhancedOpen" type="radio"
                                        name="preferred-network1" value="24"><span class="b-radio"></span>NR / LTE
                                </label>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <div class="horizontal-box" style="margin-top: 40px">
                <div class="submit-btn" onclick="freshen_click(1)">設定</div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="./js/utils.js"></script>
<script>
    var netWorkData = ''
    window.onload = function () {
        getData()
        getSimNum()
    }

    function getSimNum() {
        var num = sessionStorage.getItem('activeSimNumber')
        if (num == 0) {
            var btn = document.getElementById('x2')
            btn.onclick = function() {}
            btn.style.backgroundColor = '#eee'
        }
        var params = {}
        Ajax.post(baseUrl + '/action/getActiveSimCardNumber', JSON.stringify(params), function(res) {
            var response = JSON.parse(res)
            if (response.status == 'success') {
                sessionStorage.setItem('activeSimNumber', response.data.activeSimNumber)
            }
        })
    }

    function getData(){
        
        var params = {}
        Ajax.post(baseUrl + '/action/getPreferredNetworkType', JSON.stringify(params), function (res) {
            var response = JSON.parse(res)
            if (response.status == 'success') {
                var data = response.data
                if(data.slot0 != 'null'){
                    if(data.slot0 == 1){
                        Utils.SetRadioValue("preferred-network0", '11' || '0')
                    }
                    if(data.slot0 == 2){
                        Utils.SetRadioValue("preferred-network0", '23' || '0')
                    }
                    if(data.slot0 == 3){
                        Utils.SetRadioValue("preferred-network0", '24' || '0')
                    }
                }else{
                    document.getElementById('sim0').style.display = "none"
                }
                if(data.slot1 != 'null'){
                    if(data.slot1 == 1){
                        Utils.SetRadioValue("preferred-network1", '11' || '0')
                    }
                    if(data.slot1 == 2){
                        Utils.SetRadioValue("preferred-network1", '23' || '0')
                    }
                    if(data.slot1 == 3){
                        Utils.SetRadioValue("preferred-network1", '24' || '0')
                    }
                }else{
                    document.getElementById('sim1').style.display = "none"
                }
                
                
            } else {
                Message.showmsg(response.message)
            }
        })
    }

    function security_click(data){
        netWorkData = data
    }

    function freshen_click(data){
        var params = {
            slotId:data,
            preferredNetworkMode: netWorkData.toString()
        }
        Ajax.post(baseUrl + '/action/networkType', JSON.stringify(params), function (res) {
            var response = JSON.parse(res)
            if (response.status == 'success') {
                Message.showmsg(response.message)
            } else {
                Message.showmsg(response.message)
            }
        })
    }

</script>
</body>

</html>
